Ext.define('iMedproplus.view.component.DictionaryComboBox', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.dictionarycombobox',
    
    dictionaryId : '',
    fieldLabel: 'combobox',
    
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            displayField: 'name',
            valueField: 'code',
            editable: false,
            listeners: {
                afterrender: {
                    fn: me.onComboboxAfterRender,
                    scope: me
                }
            }
        });

        me.callParent(arguments);
    },

    onComboboxAfterRender: function(abstractcomponent, options) {
        this.store = Ext.create('Ext.data.Store', {
            model: 'iMedproplus.model.Dictionary',
            autoLoad : false,
            proxy: {
                extraParams : {
                    dictionary : this.dictionaryId
                },
                type: 'ajax',
                url: '/imedproplus-rest/rest/json/dictionary/get',
                reader: {
                    type: 'json',
                    root: 'data',
                    successProperty: 'success'
                }
            }
        });
    }
});